﻿using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Data.SqlClient;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows.Forms;

namespace WFPush1
{
    public partial class Form1 : Form
    {
        public Form1()
        {
            //conn=new SqlConnection("Data Source=.;Initial Catalog=StudentCourse;Integrated Security=True");
            ///myData = new DataSet1();
            InitializeComponent();
        }

       // SqlConnection conn;    //声明sql连接对象
      //  DataSet1 myData;       //声明数据集
       // SqlDataAdapter da;     //声明数据桥接器

        /// <summary>
        /// 构造方法：初始化对象
        /// </summary>
      /// <summary>
        /// push模式展示水晶报表
        /// </summary>
      /*  private void showReport()
        {
            //填充数据源
            da = new SqlDataAdapter("SELECT * FROM SC", conn);
            da.Fill(myData, "SC");

            //创建报表
            CrystalReport1 cr = new CrystalReport1();

            //设置报表的数据源
            cr.SetDataSource(myData);

            //设置报表视图的报表源
            crystalReportViewer1.ReportSource = cr;
        }*/
        private void Form1_Load(object sender, EventArgs e)
        {
            DataSet1 dataSet1 = new DataSet1();
            string connstring = "Data Source=.;Initial Catalog=StudentCourse;Integrated Security=True";
            CrystalReport1 oCR = new CrystalReport1();
            SqlConnection MyConn = new SqlConnection(connstring);
            MyConn.Open();
            string strSel = "Select * from SC";
            SqlDataAdapter MyAdapter = new SqlDataAdapter(strSel, MyConn);
            MyAdapter.Fill(dataSet1, "SC");
            oCR.SetDataSource(dataSet1);
            this.crystalReportViewer1.ReportSource = oCR;
            //showReport();
        }
    }
}
